package com.example.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LogInterceptor implements HandlerInterceptor {
    
    private static final Logger log = LoggerFactory.getLogger(LogInterceptor.class);
    
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        // 请求处理前
        log.info("请求开始: {}", request.getRequestURI());
        return true;
    }
    
    @Override
    public void postHandle(/*...*/) {
        // Controller方法执行后，视图渲染前
    }
    
    @Override
    public void afterCompletion(/*...*/) {
        // 请求完成后
    }
} 